package com.icourt.learn.date;


import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Date;
import java.util.Locale;

@Slf4j
public class SimpleDate {

    @Test
    public void test(){
        Instant now =Instant.now();


        Instant end =Instant.now();

       Duration timeDuration= Duration.between( now,end );
        long days=timeDuration.toDays();

        log.debug("间隔时间：{}",days );


    }


    @Test
    public void add(){

        Duration duration =Duration.ofDays( 1L );
        Instant now =Instant.now();
        now=now.plus( duration );


        DateTimeFormatter formatter =
                DateTimeFormatter.ofLocalizedDateTime( FormatStyle.FULL )
                        .withLocale( Locale.CHINA )
                        .withZone( ZoneId.systemDefault() );
        LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault());
        String format = localDateTime.format(DateTimeFormatter.ofPattern("yyyy:MM:dd HH:mm:ss"));



        log.debug("时间{}", formatter.format( now ) );
        log.debug( "格式化时间{}",format );

    }
}
